import wsgiref.handlers
import MainPage
import ResultView
import UserLogging
import TestPage
from google.appengine.ext import webapp

DEBUG = False

def real_main():
    application = webapp.WSGIApplication(
                    [('/', MainPage.MainPage),
                    ('/log', UserLogging.UserLogging),
                    ('/test', TestPage.MainPage),               
                    ('/group', ResultView.ResultView),
                    ], debug=DEBUG)
    wsgiref.handlers.CGIHandler().run(application)

def profile_main():
    # This is the main function for profiling 
    # We've renamed our original main() above to real_main()
    import cProfile, pstats
    prof = cProfile.Profile()
    prof = prof.runctx("real_main()", globals(), locals())
    print "<pre>"
    stats = pstats.Stats(prof)
    stats.sort_stats("time")  # Or cumulative
    stats.print_stats(80)  # 80 = how many to print
    # The rest is optional.
    # stats.print_callees()
    # stats.print_callers()
    print "</pre>"

if __name__ == "__main__":
    #profile_main()
    real_main()
